import * as _ from "@/utils/MyFun";
import * as TYPE from "../action-type";

let initialValue = {
  reloadFlag: true,
  aliveKeys: {}, // keepAlive 路由的 key, 重新赋值可重置 keepAlive
  blogConfig: {}, // 博客设置信息
};

const AppReducer = (state = initialValue, action) => {
  state = _.clone(state);
  switch (action.type) {
    case TYPE.APP_GETBLOGINFO:
      state.blogConfig = action.blogConfig;
      break;
    case TYPE.APP_SETACTIVEKEYS:
      state.aliveKeys[action.key] = action.val;
      break;
    case TYPE.APP_SETRELOADFLAG:
      state.reloadFlag = action.reloadFlag;
      break;
    default:
      state = { ...state };
  }
  return state;
};

export default AppReducer;
